package com.wangyadong.hobby.test.test1;

import com.wangyadong.hobby.front.model.WemailRecord;
import com.wangyadong.hobby.front.model.WuserInfo;

import java.util.Optional;

public class OptionalDemo {


    public static void main(String[] args) {
        System.out.println(nullSafe(Optional.ofNullable(null)));
    }

    public static String nullSafe(Optional<WuserInfo> wuserInfoOptional) {
        return wuserInfoOptional
                .map(WuserInfo::getRecord)
                .map(WemailRecord::getEmail)
                .orElse("UNKNOW");
    }


    public String getEmail(WuserInfo args) {
        return args.getEmai();
    }
}
